home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Files
/
Volumes
/
VolumeInfo.h
< prev
next >
Wrap
Text File
|
2000-06-23
|
4KB
|
106 lines
// VolumeInfo.h
#ifndef VolumeInfo_h
#define VolumeInfo_h
#ifndef Str_h
#include "Str.h"
#endif
#ifndef Volume_h
#include "Volume.h"
#endif
#ifndef AllocationBlock_h
#include "AllocationBlock.h"
#endif
#ifndef Drive_h
#include "Drive.h"
#endif
#ifndef Driver_h
#include "Driver.h"
#endif
#ifndef FileSystem_h
#include "FileSystem.h"
#endif
#include <Devices.h>
class VolumeInfo: public HParamBlockRec
{
private:
String31 name;
void ThrowError( OSErr );
bool Attribute( uint16 bit ) const { return ( volumeParam.ioVAtrb & bit ) != 0; }
public:
VolumeInfo();
VolumeInfo( ConstPString );
VolumeInfo( ::Volume );
VolumeInfo( uint16 index );
VolumeInfo( const VolumeInfo& );
void operator==( const VolumeInfo& );
void Get();
void Get( ConstPString );
void Get( ::Volume );
void Get( uint16 index );
bool TryToGet( uint16 index ); // returns false if the index is too large
void Set();
void Set( ::Volume );
ConstPString Name() const { return name; }
::Volume Volume() const { return ::Volume( volumeParam.ioVRefNum ); }
uint32 CreationTime() const { return volumeParam.ioVCrDate; }
uint32 ModificationTime() const { return volumeParam.ioVLsMod; }
uint32 BackupTime() const { return volumeParam.ioVBkUp; }
bool Busy() const { return Attribute( 0x0040 ); }
bool Locked() const { return Attribute( 0x8080 ); }
bool LockedByHardware() const { return Attribute( 0x0080 ); }
bool LockedBySoftware() const { return Attribute( 0x8000 ); }
AllocationBlock FirstBitmapBlock() const { return AllocationBlock( volumeParam.ioVBitMap ); }
AllocationBlock NextAllocation() const { return AllocationBlock( volumeParam.ioAllocPtr ); }
AllocationBlock FirstBlockMapBlock() const { return AllocationBlock( volumeParam.ioAlBlSt ); }
uint16 AllocationBlockCount() const { return volumeParam.ioVNmAlBlks; }
uint32 AllocationBlockSize() const { return volumeParam.ioVAlBlkSiz; }
uint32 ClumpSize() const { return volumeParam.ioVClpSiz; }
uint32 NextCatalogNode() const { return volumeParam.ioVNxtCNID; }
uint16 FreeAlloocationBlocks() const { return volumeParam.ioVFrBlk; }
uint16 Signature() const { return volumeParam.ioVSigWord; }
bool Online() const { return volumeParam.ioVDrvInfo != 0; }
bool Offline() const { return volumeParam.ioVDrvInfo == 0; }
bool Ejected() const { return Offline() && volumeParam.ioVDRefNum > 0; }
::Drive Drive() const;
::Driver Driver() const;
::FileSystem FileSystem() const { return ::FileSystem( volumeParam.ioVFSID ); }
uint16 FilesInRoot() const { return volumeParam.ioVNmFls; }
uint32 FileCount() const { return volumeParam.ioVFilCnt; }
uint32 DirectoryCount() const { return volumeParam.ioVDirCnt; }
uint32 WriteCount() const { return volumeParam.ioVWrCnt; }
void SetName( ConstPString newName ) { name = newName; }
void SetCreationTime( uint32 time ) { volumeParam.ioVCrDate = time; }
void SetModificationTime( uint32 time ) { volumeParam.ioVLsMod = time; }
void SetBackupTime( uint32 time ) { volumeParam.ioVBkUp = time; }
void Lock() { volumeParam.ioVAtrb |= int16(0x8000); }
void Unlock() { volumeParam.ioVAtrb &= int16(~0x8000); }
};
#endif